package com.dao.imp;

import java.util.List;

import org.hibernate.Query;

import com.dao.ClassinfoDao;
import com.dao.core.DaoBaseImp;
import com.page.PageDiv;
import com.pojo.Classinfo;

public class ClassinfoDaoImp extends DaoBaseImp<Classinfo> implements ClassinfoDao{

	@Override
	public PageDiv<Classinfo> getAllClassinfobypage(int offSet, int pageSize) {
		if(offSet>=0&&pageSize>0)
		{
			String hql="from Classinfo";
			Query q=getSession().createQuery(hql);
			q.setMaxResults(pageSize);
			q.setFirstResult(offSet);
			List<Classinfo> list=q.list();
			int totalCount=this.getCountQuery(hql);
			return new PageDiv<Classinfo>(offSet,pageSize,totalCount,list);
		}
			
		else
			return new PageDiv<Classinfo>();
	}
	@Override
	public List<Classinfo> getAllClassinfo() {
			String hql="from Classinfo as ci";
			Query q=getSession().createQuery(hql);
			List<Classinfo> list=q.list();
			int totalCount=this.getCountQuery(hql);
			return list;
	}
	
}